package com.meeting.utils;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;

import java.time.LocalDateTime;

public class QueryTimeWrapperBuilder {

    public static <T> LambdaQueryWrapper<T> buildTimeRangeWrapper(
            SFunction<T, ?> startGetter,
            SFunction<T, ?> endGetter,
            LocalDateTime start,
            LocalDateTime end)
    {
        LambdaQueryWrapper<T> wrapper = new LambdaQueryWrapper<>();
        if (start != null) {
            wrapper.gt(startGetter, start);
        }
        if (end != null) {
            wrapper.lt(endGetter, end);
        }
        return wrapper;
    }
}
